package es.valma.VideoClub.Servlet;

import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;

import es.valma.VideoClub.html.transformador.VideoClubSvGeneradorXmlXsl;


public class VideoClubSvServletVideoStreaming {

		public VideoClubSvServletVideoStreaming(){
			super();
		}
		
		protected void doPost(javax.servlet.http.HttpServletRequest arg0, javax.servlet.http.HttpServletResponse arg1) throws javax.servlet.ServletException, java.io.IOException {
			doGet(arg0, arg1);
		}

		protected void doGet(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws javax.servlet.ServletException, java.io.IOException {
			String user=httpServletRequest.getParameter("user");
			String password=httpServletRequest.getParameter("password");
//			String pass=httpServletRequest.getParameter("password");

			PrintWriter out=new PrintWriter(httpServletResponse.getOutputStream());
			String retorno;
			if(user!=null && password!=null){
				//TODO Acceso a BBDD y comprobar user and password
				if(user.equals("Valma")){
					retorno="<html><h1>Te has logado OK "+user+"</h1></html>";
				}else{
					retorno="<html><h1>ERROR EN EL LOGIN!!</h1></html>";
				}
			}else{
				retorno=VideoClubSvGeneradorXmlXsl.tranformadorXmlXsl("login.xml", "login.xsl");
				//retorno="<html><h1>Valma eres el puto amo!!!</h1><form name=\"myform\" action=\"http://localhost:9082/VideoClubWebDinamico/Logon\" method=\"POST\"><div align=\"center\"><br><br><input type=\"text\" size=\"25\" value=\"\" name=\"user\" id=\"user\"><br><input type=\"submit\" value=\"Enviar\"><br></div></form></html>";
			}
			out.print(retorno);
			out.flush();
			out.close();
		}	

}


